package com.example.intentfiltertester;

import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ReceiverTestActivity extends BaseListActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        String[] uris = getResources().getStringArray(R.array.actions);
        setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, uris));
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        String uri = (String) l.getAdapter().getItem(position);
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(uri));
        try {
            startActivity(intent);
        } catch (ActivityNotFoundException e) {
            Log.e("ReceiverTestActivity", e.getMessage(), e);
        }
    }
}